home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Burning & Media
/
GB-PVR 1.2.13
/
GBPVR10213.msi
/
Cabs.w1.cab
/
Library.aspx.cs618
< prev
next >
Wrap
Text File
|
2008-02-23
|
8KB
|
235 lines
//===========================================================================
// This file was modified as part of an ASP.NET 2.0 Web project conversion.
// The class name was changed and the class modified to inherit from the abstract base class
// in file 'App_Code\Migrated\Stub_Library_aspx_cs.cs'.
// During runtime, this allows other classes in your web application to bind and access
// the code-behind page using the abstract base class.
// The associated content page 'Library.aspx' was also modified to refer to the new class name.
// For more information on this code pattern, please refer to http://go.microsoft.com/fwlink/?LinkId=46995
//===========================================================================
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI.WebControls;
using GBPVR.Public;
using gbweb.classes;
namespace gbweb
{
/// <summary>
/// Summary description for Library.
/// </summary>
public partial class Migrated_Library : Library
{
protected string Mode;
protected string DisplayPath;
private Settings guideParams;
protected void Page_Load(object sender, EventArgs e)
{
Session["GuideStartTime"] = null;
playAlbum.Visible = false;
guideParams = Global.Settings;
streamAlbum.Visible = false;
bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
string vpath = string.Empty;
if ((Request["path"] != null) && (Request["path"].Length != 0))
{
vpath = Request["path"];
}
string[] pathparts = vpath.Split(new char[] {'/'}, 3);
Mode = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(pathparts[0]);
Regex fileFilter = GetRegex(Mode);
header.ActiveTab = Mode.ToLower() + "library";
string path = GetRealPath(vpath);
ArrayList folders = new ArrayList();
ArrayList files = new ArrayList();
if (pathparts.Length == 1)
{
Hashtable directories = (Hashtable)HttpContext.Current.Session[Mode + "LibraryDirectories"];
ArrayList keys = new ArrayList(directories.Keys);
keys.Sort();
foreach (string name in keys)
folders.Add(name);
}
else
{
if (pathparts.Length == 2)
DisplayPath = " - " + pathparts[1];
else if (pathparts.Length == 3)
{
DisplayPath = " - " + pathparts[1] + "/" + pathparts[2];
}
try
{
folders.Add("..");
string[] dirs = Directory.GetDirectories(path);
Array.Sort(dirs);
foreach (string dir in dirs)
{
if (dir == Path.GetFullPath(dir))
folders.Add(Path.GetFileName(dir));
}
string[] filenames = Directory.GetFiles(path);
Array.Sort(filenames);
foreach (string filename in filenames)
{
if (filename == Path.GetFullPath(filename))
files.Add(Path.GetFileName(filename));
}
}
catch (Exception ex)
{
Logger.Error(ex.ToString());
}
}
string root = string.Join("/", pathparts);
if (root.Length > 0) root += "/";
TableCell colOpt = new TableCell();
TableCell colShow = new TableCell();
TableRow recordingRow;
foreach (string folder in folders)
{
recordingRow = new TableRow();
recordingRow.CssClass = "library_row";
colShow = new TableCell();
colShow.VerticalAlign = VerticalAlign.Top;
colShow.CssClass = "folder";
if (folder != "..")
{
path = Server.UrlEncode(root) + Server.UrlEncode(folder);
}
else
{
path = string.Join("/", pathparts);
path = path.Substring(0, path.LastIndexOf("/"));
path = Server.UrlEncode(path);
}
colShow.Text = "<a href=\"?path=" + path + "\" >[" + folder + "]</a>";
recordingRow.Cells.Add(colShow);
libraryView.Rows.Add(recordingRow);
}
//Need to remove the variable holder since it is only used by the CSS Library display
Regex coverFilter = new Regex(Global.Settings.coverFiles.Replace("~|", ""), RegexOptions.Compiled | RegexOptions.IgnoreCase);
string coverImage = null;
string strmAlbumLink = null;
foreach (string file in files)
{
if (fileFilter.IsMatch(file))
{
playAlbum.Visible = true;
recordingRow = new TableRow();
recordingRow.CssClass = "library_row";
colShow = new TableCell();
colShow.VerticalAlign = VerticalAlign.Top;
colShow.CssClass = "file";
colShow.Text =
file + "</a><br></br>";
if (strmAllowed)
{
if (Mode.ToLower() == "music")
{
colShow.Text += "<a href=\"public/Player.aspx?playerType=2&mvid=" +
PublicDownload.Serialize(root + file) +
"\" onclick=\"EditPop5(this.href,'Add1');return false;\" class=\"btn-normal-small\"><span>Stream</span></a>";
}
else
{
colShow.Text += "<a href=\"public/Player.aspx?playerType=1&mvid=" +
PublicDownload.Serialize(root + file) +
"\" onclick=\"EditPop5(this.href,'Add1');return false;\" class=\"btn-normal-small\"><span>Stream</span></a>";
}
}
colShow.Text += "<a href=\"" + Download.GetDownloadUrl(false, false, Download.InternalFiles.LibraryFile, root + file) + "\" class=\"btn-normal-small\"><span>Play</span></a>" +
"<a href=\"" + Download.GetDownloadUrl(true, true, Download.InternalFiles.LibraryFile, root + file) + "\" class=\"btn-normal-small\"><span>Download</span></a>";
recordingRow.Cells.Add(colShow);
libraryView.Rows.Add(recordingRow);
}
if ((coverFilter.IsMatch(file) && (coverImage == null)))
{
coverImage = Download.GetDownloadUrl(false, true, Download.InternalFiles.LibraryFile, root + file);
}
}
//strmAlbumLink = "public/Player.aspx?mid=" + PublicDownload.Serialize(root) + "\" onclick=\"EditPop5(this.href,'Add1');return false;\"";
if (coverImage != null)
{
coverArt.Attributes.Add("background", coverImage);
}
downloadAlbum.Visible = playAlbum.Visible;
if (playAlbum.Visible)
{
playAlbum.HRef = Download.GetDownloadUrl(false, false, Download.InternalFiles.LibraryFolder, root);
downloadAlbum.HRef = Download.GetDownloadUrl(true, true, Download.InternalFiles.LibraryFolder, root);
if (strmAllowed)
{
if (Mode.ToLower() == "music")
{
streamAlbum.HRef = "public/Player.aspx?playerType=2&mid=" + PublicDownload.Serialize(root) +
"\" onclick=\"EditPop5(this.href,'Add1');return false;\"";
}
else
{
streamAlbum.HRef = "public/Player.aspx?playerType=1&mid=" + PublicDownload.Serialize(root) +
"\" onclick=\"EditPop5(this.href,'Add1');return false;\"";
}
streamAlbum.Visible = true;
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}